<?php

namespace api\modules\user\controllers;

use Yii;
use api\components\Controller;
use api\models\DynamicSearch;
use api\models\ArticleSearch;

/**
 * 个人发表的内容相关接口
 * Default controller for the `user` module
 */
class PublishedController extends Controller {

    /**
     * 动态
     * @inheritdoc
     */
    public function actionDynamic($id) {
        $modelClass = new DynamicSearch();
        return $modelClass->search($id);
    }

    /**
     * 文章
     * @inheritdoc
     */
    public function actionArticle($id) {
        $modelClass = new ArticleSearch();
        return $modelClass->search([
            'and',
            ['user_id' => $id],
            ['!=', 'type', ArticleSearch::TYPE_VIDEO],
        ]);
    }

    /**
     * 视频
     * @inheritdoc
     */
    public function actionVideo($id) {
        $modelClass = new ArticleSearch();
        return $modelClass->search([
            'user_id' => $id,
            'type' => ArticleSearch::TYPE_VIDEO,
        ]);
    }

}
